package com.zkthink.base.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Author Xiaoyan
 * @create 2021/11/11 10:17
 */
@Getter
@Setter
@Accessors(chain = true)
@ToString(callSuper = true)
public class AppBaseEntity<T> implements Serializable {
    public static final String FIELD_ID = "id";
    public static final String CREATE_TIME = "createTime";
    public static final String CREATE_TIME_COLUMN = "create_time";
    public static final String CREATE_USER = "createUser";
    public static final String CREATE_USER_COLUMN = "create_user";
    public static final String UPDATE_TIME = "updateTime";
    public static final String UPDATE_USER = "updateUser";
    private static final long serialVersionUID = 5169873634279173683L;

    @TableId(value = "id", type = IdType.INPUT)
    @ApiModelProperty(value = "主键")
    @NotNull(message = "id不能为空", groups = SuperEntity.Update.class)
    protected T id;


    @ApiModelProperty(value = "创建时间")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    protected LocalDateTime createTime;

    @ApiModelProperty(value = "创建人ID")
    @TableField(value = "create_user", fill = FieldFill.INSERT)
    protected T createUser;


    @ApiModelProperty(value = "最后修改时间")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;

    @ApiModelProperty(value = "最后修改人ID")
    @TableField(value = "update_user", fill = FieldFill.INSERT_UPDATE)
    protected T updateUser;

    @ApiModelProperty(value = "逻辑删除")
    @TableField(value = "is_delete")
    @TableLogic(value = "0",delval = "1")
    protected Integer isDelete;

    public AppBaseEntity(T id, LocalDateTime createTime, T createUser, LocalDateTime updateTime, T updateUser, Integer isDelete) {
        this.createTime = createTime;
        this.createUser = createUser;
        this.id = id;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.isDelete = isDelete;
    }

    public AppBaseEntity() {
    }


}
